package com.hqyj.service.impl;

import com.hqyj.dao.UserRoleMapper;
import com.hqyj.pojo.DataMessage;
import com.hqyj.pojo.Role;
import com.hqyj.pojo.User;
import com.hqyj.pojo.UserRole;
import com.hqyj.service.UserRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserRoleServiceImpl implements UserRoleService {
    @Autowired
    UserRoleMapper userRoleMapper;
    @Override
    public DataMessage updateRole(UserRole userRole) {
            DataMessage data = new DataMessage();
            int num = userRoleMapper.updateByPrimaryKey(userRole);
            if (num > 0){
                data.setSuccess(true);
                data.setInfo("更改成功");
            }else {
                data.setSuccess(false);
                data.setInfo("更改失败");
            }
            return data;

    }

    @Override
    public DataMessage add(UserRole userRole) {
        DataMessage data = new DataMessage();
        int num = userRoleMapper.insert(userRole);
        if (num > 0){
            data.setSuccess(true);
            data.setInfo("更改成功");
        }else {
            data.setSuccess(false);
            data.setInfo("更改失败");
        }
        return data;
    }


}
